<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="用户名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入微信用户名" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table :data="weixinlizhiList">
      <el-table-column label="微信用户id" align="center" prop="userid" />
      <el-table-column label="微信联系电话" align="center" prop="mobile" />
      <el-table-column label="微信用户名" align="center" prop="name" />
      <el-table-column label="离职日期" align="center" prop="createTime" width="180">
        <template v-slot="scope">
          <DateFormat :value="scope.row.createTime" :format="'YYYY-MM-DD HH:mm'"></DateFormat>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination class="center" background layout="total, prev, pager, next" v-show="total>0"
                   @current-change="getList" :total="total"
                   :current-page.sync="queryParams.pageNum" :page-size="queryParams.pageSize">
    </el-pagination>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 微信离职表格数据

      weixinlizhiList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
      }
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      request({
        url: '/iraeta/weixinlizhi/list',
        params: this.queryParams
      }).then(response => {
        this.weixinlizhiList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  }
};
</script>
